//
//  PhotosetCell.m
//  RoadKnowEntertainment
//
//  Created by lanou on 16/8/8.
//  Copyright © 2016年 RKE. All rights reserved.
//

#import "PhotosetCell.h"
#import "UIImageView+WebCache.h"
@interface PhotosetCell ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *imgView1;
@property (nonatomic, strong) UIImageView *imgView2;
@property (nonatomic, strong) UIImageView *imgView3;


@end

@implementation PhotosetCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initLayout];
    }
    return  self;
    
    
}

- (void)initLayout {
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, kwidth - 10, 20)];
    titleLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:titleLabel];
    
    UIImageView *imgView1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(titleLabel.frame) + 5, (kwidth - 60) / 3, normalCellHeight - 10 - 5 - CGRectGetHeight(titleLabel.frame))];
   
    [self.contentView addSubview:imgView1];
    
    UIImageView *imgView2 = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imgView1.frame) + 20, CGRectGetMaxY(titleLabel.frame) + 5, (kwidth - 60) / 3, normalCellHeight - 10 - 5 - CGRectGetHeight(titleLabel.frame))];
   
    [self.contentView addSubview:imgView2];
    
    UIImageView *imgView3 = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imgView2.frame) + 20, CGRectGetMaxY(titleLabel.frame) + 5, (kwidth - 60) / 3, normalCellHeight - 10 - 5 - CGRectGetHeight(titleLabel.frame))];
   
    [self.contentView addSubview:imgView3];
    
    
    self.titleLabel = titleLabel;
    self.imgView3 = imgView3;
    self.imgView2 = imgView2;
    self.imgView1 = imgView1;
    
}

- (void)setModel:(TopStoriesModel *)model {
    UIImage *placeImage = [UIImage imageNamed:@""];
    if ([model.skipType isEqualToString:@"photoset"]) {
        self.titleLabel.text = model.title;
        
        [self.imgView1 sd_setImageWithURL:[NSURL URLWithString:model.imgsrc] placeholderImage:placeImage];
        [self.imgView2 sd_setImageWithURL:[NSURL URLWithString:model.imgextra[0].imgsrc] placeholderImage:placeImage];
        [self.imgView3 sd_setImageWithURL:[NSURL URLWithString:model.imgextra[1].imgsrc] placeholderImage:placeImage];
        
    }
    
}

@end
